package com.learn.security.oauth2.auth.server.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.stereotype.Component;

/**
 * 授权事件
 *
 * @author knight
 */
@Component
@Slf4j
public class AuthenticationEvents {

	@EventListener
	public void onSuccess(AuthenticationSuccessEvent success) {
		log.info("登陆成功: {}", success.getAuthentication());
	}

	@EventListener
	public void onFailure(AbstractAuthenticationFailureEvent failures) {
		log.info("登陆失败: {}", failures.getAuthentication());
	}

}